package interfaz;


import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.ImageIcon;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Shadow
 */
public class Grafica extends javax.swing.JPanel {

    /**
     * Creates new form Grafica
     */
     ImageIcon img;
     Graphics2D g2;
     double max[],min[],prom[];
     String strTemp[]=new String[4];
     int foo;
    
    public Grafica(String name,double[] max,double[] min,double[] prom,int foo) {
        this.foo=foo;
       initComponents();
       img=new ImageIcon(getClass().getResource(name));
       setSize(img.getIconWidth(),img.getIconHeight());
       this.max=max;
       this.min=min;
       this.prom=prom;
    }
    
    public void setData(double[] max,double[] min,double[] prom){
        this.max=max;
        this.min=min;
        this.prom=prom;
        this.repaint();
    }

    public void setIdioma(int foobar){
        this.foo=foobar;
        this.repaint();
    }
    
    @Override            
    protected void paintComponent(Graphics g) {
        Dimension d=getSize();
        g.drawImage(img.getImage(), 0, 0, d.width, d.height,this);
        setOpaque(false);
        super.paintComponent(g);
        
        g2 = (Graphics2D)g;
        
        int k,ymax,ymin,yprom;
        k=50;
        g2.drawLine(50,50,50,300);//vertical
        for(int i=0;i<10;i++,k+=25){
            g2.drawString((10-i)+"", 30, k);
            g2.drawLine(45,k,55,k);
        }
        
        k=100;
        g2.drawLine(50,300,450,300);//horizontal
        for(int i=0;i<4;i++,k+=100)
            g2.drawLine(k,295,k,305);
        //interface de qualité
        strTemp[0]="Uso del              Calida de la           Calidad de la              General";
        strTemp[1]="Use of                   Quality of                  Quality                  General";
        strTemp[2]="Verwendung          Qualität der              Qualität                  General";
        strTemp[3]="L'utilisation           Qualité de                  Interface                Général";
        g2.drawString(strTemp[foo], 80, 320);
        strTemp[0]="Sistema              Información                Interfaz";
        strTemp[1]="the System           Information              Interface";
        strTemp[2]="des Systems          Informationen      Schnittstelle";
        strTemp[3]="du Système           L'information            de Qualité";
        g2.drawString(strTemp[foo], 80, 335);
        
        k=100;
        for(int i=0;i<4;i++,k+=100){
            ymax=(int)(max[i]*25);
            ymin=(int)(min[i]*25);
            yprom=(int)(prom[i]*25);
            g2.drawLine(k, 300-ymax, k, 300-ymin);
            g2.drawLine(k-5, 300-yprom, k+5, 300-yprom);
        }
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}
